import 'package:flutter/material.dart';

class UserAvatar extends StatefulWidget {
  const UserAvatar({super.key});

  @override
  _UserAvatarState createState() => _UserAvatarState();
}

class _UserAvatarState extends State<UserAvatar> {
  bool isHovering = false;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        debugPrint("tap");
        // Scaffold.of(context).openEndDrawer();
      },
      child: MouseRegion(
        cursor: SystemMouseCursors.click,
        onEnter: (event) {
          setState(() {
            isHovering = true;
          });
        },
        onExit: (event) {
          setState(() {
            isHovering = false;
          });
        },
        child: Column(
          children: [
            const CircleAvatar(
              radius: 30,
              child: Icon(
                Icons.account_circle,
                size: 60,
              ),
            ),
            const Padding(padding: EdgeInsets.only(top: 10)),
            Text(
              "前往登录",
              style: isHovering
                  ? TextStyle(
                      decoration: TextDecoration.underline,
                      decorationStyle: TextDecorationStyle.solid,
                      decorationThickness: 1,
                      decorationColor: Theme.of(context).primaryColor,
                      color: Theme.of(context).primaryColor,
                    )
                  : null,
            ),
            const Padding(padding: EdgeInsets.only(top: 10)),
          ],
        ),
      ),
    );
  }
}
